package com.example.demo.demos.handle;

import com.example.demo.demos.common.CommonEnum;
import com.example.demo.demos.common.ResultBody;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.logging.Logger;

@ControllerAdvice
public class GlobalExceptionHandler {




    /**
     * 处理空指针的异常
     * @param req
     * @param e
     * @return
     */
    @org.springframework.web.bind.annotation.ExceptionHandler(value =NullPointerException.class)
    @ResponseBody
    public ResultBody exceptionHandler(HttpServletRequest req, NullPointerException e){

        return ResultBody.error(CommonEnum.INTERNAL_SERVER_ERROR);
    }

}
